package com.py.credit.service.excel.read.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.py.credit.entity.Column;
import com.py.credit.service.excel.read.InspectHandles;
import com.py.credit.service.excel.read.service.InspectDataStyleService;
import com.py.credit.service.excel.read.service.RuleCheckService;

/**
 * 信用评价模块数据入库走的校验
 *
 * @author YaoS
 * @date 2019-04-03 10:02
 */
@Service("xypj")
public class XypjInspectDataStyleServiceImpl extends InspectDataStyleServiceImpl implements InspectDataStyleService {

    @Autowired
    private RuleCheckService ruleCheck;

    /**
     * 功能描述: 信用评价数据校验
     *
     * @param tableId 资源id
     * @param map     待校验数据
     * @param columns 字段信息
     * @return 校验结果
     * @author YaoS
     * @date 18/11/6 17:36
     */
    @Override
    public String dataCheck(int tableId, Map<String, Object> map, List<Column> columns) {
        // 数据库规则校验
        String dbCheck = InspectHandles.singleDataFormatCheck(map, columns, data -> data.split(" ")[0],tableId);
        if (StringUtils.isNotBlank(dbCheck)) {
            return dbCheck;
        }
        return ruleCheck.ruleCheck(tableId, map, columns);
    }

}
